package com.perceptivesoftware.licensing.scheduled;

import javax.annotation.PostConstruct;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.perceptivesoftware.licensing.server.handler.PropertiesHandler;
import com.perceptivesoftware.licensing.server.util.PropertiesUtil;

@Service
public class ScheduledServlet
{
	protected Log logger = LogFactory.getLog(getClass());

	@Autowired
	private PropertiesUtil propertiesUtil;

	final PropertiesHandler propertiesHandler = new PropertiesHandler();

	@SuppressWarnings("unused")
	@Transactional
	@Scheduled(cron = "0 0 */1 * * *")
	private void hourly()
	{
		propertiesUtil.dumpVersionInfo(false);
	}

	@SuppressWarnings("unused")
	@Transactional
	@Scheduled(cron = "0 */1 * * * *")
	private void everyMinute()
	{}

	@SuppressWarnings("unused")
	@PostConstruct
	private void startup()
	{
		propertiesUtil.dumpVersionInfo(true);
	}
}